# 功能
# 开启https 服务验证https证书
import http.server
import ssl
import socket 
# import os
with open(r'E:/Hayes/smp/smp_ubuntu/localhost+2-key.pem', 'r') as f:
    key_data = f.read()
    print(key_data)



context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
context.load_cert_chain(certfile='E:\\Hayes\\smp\\smp_ubuntu\\localhost+2.pem', keyfile='E:\\Hayes\\smp\\smp_ubuntu\\localhost+2-key.pem')

httpd = http.server.HTTPServer(('0.0.0.0', 8000), http.server.SimpleHTTPRequestHandler)
httpd.socket = context.wrap_socket(httpd.socket, server_side=True) 
server_port = httpd.server_port 
local_ip = socket.gethostbyname(socket.gethostname())

print(f"Server started at https://{local_ip}:{server_port}") 
httpd.serve_forever() 